/****************************************
* James Gomez                           *
* Project 3: Target Practice P3         *
* Comp 465                              *
* Professor Barnes                      *
* 12/7/2012                             *
*****************************************/

#ifndef _COLLIDABLE_OBJECT_
#define _COLLIDABLE_OBJECT_

#include "GomezJamesP3_OpenGL.h"
#include "GomezJamesP3_Object3D.cpp"
#include <math.h>
#include <string>

using namespace std;

class CollidableObject: public Object3D{

private:
	GLfloat cRadius;
	
public:
	CollidableObject(const string name, const GLfloat radius): Object3D(name){ cRadius = radius; }
	~CollidableObject(){}

	GLfloat collisionRadius() const { return cRadius; }

	/* child classes may choose to override this method */
	virtual bool checkForCollisions(CollidableObject * object);	

	GLfloat distance(CollidableObject * obj);

};

bool CollidableObject::checkForCollisions(CollidableObject * obj){
	if ( distance(obj) <= (cRadius + obj->collisionRadius()) )
		return true;
	
	return false;
}

GLfloat CollidableObject::distance(CollidableObject * obj){
	return sqrt( 
		pow(obj->getX() - getX(), 2) + 
		pow(obj->getY() - getY(), 2) + 
		pow(obj->getZ() - getZ(), 2) 
	);
}


#endif